In windows, range(1,5) not showing expected output [1,2,3,4,5], Why?
Title
Question
In windows, range(1,5) not showing expected output [1,2,3,4,5], Why?
Python-3.4.3 Getting-started-with-for 10-11 min 0-10 sec
Answers:
This is not the expected output. When you run the function range, it will start from the mentioned starting point and it will end one before the destination point. In this particular case, you will be getting the output as [1,2,3,4] and not [1,2,3,4,5]. To get the output as [1,2,3,4,5], you need to write the following range function:
range(1,6)
Regards.
Login to add comment